Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

511
Views
Comando de barra no registrado - DiscordAPIError: cuerpo de formulario no válido, 0.opciones[2].tipo: este campo es obligatorio

Tengo un bot de Discord que tiene un comando de barra; /info . Mi intención es tener un subcomando ( server ) ejecutado sin necesidad de especificar un valor.

Este código, sin embargo, no me permite hacer eso. En su lugar, arroja un error al iniciar el bot.

 const { Client, CommandInteraction } = require("discord.js"); const { SlashCommandBuilder } = require("@discordjs/builders"); module.exports = { ...new SlashCommandBuilder() .setName("info") .setDescription("Displays information regarding the current server or specified user") .addUserOption((option) => option .setName("user") .setDescription("Displays information regarding the specified user") ) .addUserOption((option) => option .setName("member") .setDescription("Displays information regarding the specified guild member") ) .addSubcommand((subcommand) => subcommand .setName("server") .setDescription("Displays information regarding the current server") ), // ...

Error

 F:\GitHub\Discord Bots\Bailey-v4\node_modules\discord.js\src\rest\RequestHandler.js:350 throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: Invalid Form Body 0.options[2].type: This field is required at RequestHandler.execute (F:\GitHub\Discord Bots\Bailey-v4\node_modules\discord.js\src\rest\RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (F:\GitHub\Discord Bots\Bailey-v4\node_modules\discord.js\src\rest\RequestHandler.js:51:14) at async GuildApplicationCommandManager.set (F:\GitHub\Discord Bots\Bailey-v4\node_modules\discord.js\src\managers\ApplicationCommandManager.js:146:18) at async Client.<anonymous> (F:\GitHub\Discord Bots\Bailey-v4\handler\index.js:44:9)

¡La ayuda (en cualquiera) sería muy apreciada!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No creo que puedas mezclar el método addSubcommand() con otros métodos como addUserOption() . Los tipos de opciones de subcomandos y grupos de subcomandos son mutuamente excluyentes para todos los demás tipos.

Para resolver esto, deberá configurar dos subcomandos más:

 new SlashCommandBuilder() .setName('info') .setDescription( 'Displays information regarding the current server or specified user', ) .addSubcommand((subcommand) => subcommand .setName('user') .setDescription('Displays information regarding the specified user') .addUserOption((option) => option.setName('target') .setDescription('The user') .setRequired(true), ), ) .addSubcommand((subcommand) => subcommand .setName('member') .setDescription('Displays information regarding the specified guild member') .addUserOption((option) => option .setName('target') .setDescription('The member') .setRequired(true), ), ) .addSubcommand((subcommand) => subcommand .setName('server') .setDescription('Displays information regarding the current server'), )

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!